package com.efesco.payroll.classItem;

import java.util.List;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.utils.variant.VariantSet;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.efesco.common.Tools;

/**
 * classItemViewViewModel
 */
public class classItemViewViewModel extends DefaultViewModel {
	protected void initDatasets() throws Exception {
		super.initDatasets();
		Dataset ds = this.getDataset("datasetClassItem");
		DoradoContext context = DoradoContext.getContext();
		String waClassItemId = context.getParameter("wa_classitem_id");
		DBStatement statement = new DBStatement();
		String sql = "select data_from,data_of_contract from s_wa_classitem where wa_classitem_id="
				+ waClassItemId;
		statement.setSql(sql);
		VariantSet var = statement.query();
		String dataFrom=var.getString(0);
		statement.close();
		ViewBaseField field=null;
		ViewLookupField field1=null;
		field=(ViewBaseField)ds.getField("FORMULA_DISPLAY");
		field.setVisible(false);
		field=(ViewBaseField)ds.getField("FIX_AMOUNT");
		field.setVisible(false);
		//field1=(ViewLookupField)ds.getField("tmpName1");
		//field1.setVisible(false);
		field=(ViewBaseField)ds.getField("DATA_OF_CONTRACT_NAME");
		field.setVisible(false);
		if ("1".equals(dataFrom)) {
			field=(ViewBaseField)ds.getField("FORMULA_DISPLAY");
			field.setVisible(true);			
		} else if ("2".equals(dataFrom)) {
			field=(ViewBaseField)ds.getField("FIX_AMOUNT");
			field.setVisible(true);
		} else if ("3".equals(dataFrom)) {
		} else if ("4".equals(dataFrom)) {
			field1=(ViewLookupField)ds.getField("tmpName1");
			field1.setVisible(true);
		} else if ("5".equals(dataFrom)) {
			field=(ViewBaseField)ds.getField("DATA_OF_CONTRACT_NAME");
			field.setVisible(true);			
		}
		//System.out.println("111111111111111111111111111111");
	}

	protected void initControls() throws Exception {
		super.initControls();
		// Add your code here
	}

}
